import axios from "axios";
import adapter from "./lib/adapter"

const service = axios.create({
  withCredentials: true,
  baseURL: '/api',
  timeout: 6000
})

service.defaults.adapter = adapter;
service.defaults.retry = 5; // 设置请求次数
service.defaults.retryDelay = 1000;// 重新请求时间间隔

service.interceptors.response.use(res => {
  if (res.status == 200) {
    return res;
  } else {
    return Promise.reject(res);
  }
}, err => axiosError(err, service))

export default service